<template>
    <a-switch v-model:checked="is_on" @change="change"/>
</template>

<script>

export default {
    name: "YesOrNo",
    props: {
        value: {
            type: Number,
            default: null,
        }
    },
    watch: {
        value: {
            handler(newV, oldV) {
                // console.log(2222, newV)
                this.is_on = newV === 1
            },
            immediate: true
        }
    },
    data: function () {
        return {
            is_on: false,
        };
    },
    methods: {
        change(e) {
            this.$emit('update:value', e ? 1 : 0)
        },
    }
}
</script>

<style scoped lang="less">

</style>